<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FDTextBox Test</title>
<!-- css -->
<link id="fd_theme" href="../../styles/theme/aristo/theme.css" rel="stylesheet" type="text/css" />
<link href="../../styles/primeui-1.1-min.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body{font-size: 12px;background-color: white;}
</style>
<!-- lib -->
<script type="text/javascript" src="../../src/FDLib/FDLib.js"></script>
<script type="text/javascript" src="../../src/JsMap.js"></script>
<!-- app js -->
<script type="text/javascript" src="../theme.js"></script>
<script type="text/javascript">
FDLib.setDir('../../src/');
//FDLib.openDebug();
var txtUsername;
var txtPassword

FDLib.loadJs(['FDTextBox','FDPasswordBox'],function() {
	txtUsername = new FDTextBox({domId:'username',name:"username",msgId:"msgId"
		,nativeAttr:{'placeholder':'请输入用户名'}
		,validates:[
					{rule:{notNull:true},successClass:'success',errorClass:'error',successMsg:'√',errorMsg:'用户名不能为空'}
					]});
	
	
	txtPassword = new FDPasswordBox({domId:'password',name:'password',nativeAttr:{'placeholder':'请输入密码'}});
	
	var text2 = new FDTextBox({domId:'addr',width:200,height:40,name:'addr',label:'地址:',defaultValue:'12'});
	text2.addEvent('change',function(e){
		alert(e.target.value);
	})
});

function getValue() {
	var val = txtUsername.getValue()
	alert(val)
}
function setValue() {
	txtUsername.setValue('zhangsan');
	txtPassword.setValue('123456');
	
}
function getData() {
	var data = txtUsername.getData()
	var s = '';
	for(var key in data) {
		s += key + ":" + data[key]
	}
	
	alert(s);
}
function disable() {
	txtUsername.disable();
}
function enable() {
	txtUsername.enable();
}
function show() {
	txtUsername.show();
	txtPassword.show();
}
function hide() {
	txtUsername.hide();
	txtPassword.hide();
}

function validate() {
	var val = txtUsername.validate();
} 
function reset() {
	txtUsername.reset();
} 
</script>

</head>
<body>
<div id="msgId"></div>
<table cellpadding="0" cellspacing="0">
	<tr>
		<td>用户名:</td>
		<td id="username"></td>
	</tr>
	<tr>
		<td>密码:</td><td id="password" ></td>
	</tr>
</table>
<div id="addr"></div>
<button onclick="setValue()">setValue</button>
<button onclick="getValue()">getValue</button>
<button onclick="getData()">getData</button>
<button onclick="disable()">disable</button>
<button onclick="enable()">enable</button>
<button onclick="hide()">hide</button>
<button onclick="show()">show</button>
<button onclick="reset()">reset</button>
<br>
<button onclick="validate()">validate</button>

</body>
</html>